fix(cli): make logicsrc update actually check for updates - #103
Merged
Conversation
`update` was three hardcoded console.log lines: it printed 0.1.0 as both current and latest, claimed "already up to date", and never checked or installed anything. `--version` was hardcoded the same way. A version comparison alone could not have worked either. install.sh ships a tarball of the master branch, not a tagged release, and packages/cli/package.json has been 0.1.0 since the repo began, so version equality says "up to date" no matter how far master has moved. The commit is the real signal. - install.sh records ref/commit/version/installed_at to $LOGICSRC_HOME/install.json. The sha comes from GitHub's Accept: application/vnd.github.sha media type, so this needs no jq. It is resolved before the download on purpose: if master moves mid-install we under-report (a spurious update) rather than falsely claim to be current. - update compares the installed commit against the remote ref head, falls back to version comparison for installs predating the manifest, and reports why it reached its verdict instead of just asserting one. --check reports without installing; otherwise it re-runs the installer. - --version now reads the package's real version. Verified against live GitHub in all three states: matching commit, stale commit, and no manifest. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
That was the only output the command could produce. It was three hardcoded
console.loglines inpackages/cli/src/index.ts— no check, no install, no network call.program.version("0.1.0")was hardcoded the same way.Why a version check alone wouldn't fix it
install.shinstalls a tarball of themasterbranch, not a tagged release.packages/cli/package.jsonhas been0.1.0since the repo began (0 tags, 0 releases) while master gets commits continuously. Comparing versions would report "up to date" forever, no matter how far master had moved. The commit is the real signal.Changes
install.shwrites$LOGICSRC_HOME/install.json(ref,commit,version,installed_at). Without a record of what was installed, the CLI can only guess it is current. The sha comes from GitHub'sAccept: application/vnd.github.shamedia type, which returns bare text — nojqdependency. Resolved before the download deliberately: if master moves mid-install we under-report (a spurious update offer, self-correcting) rather than falsely claim currency.packages/cli/src/update.ts(new) — commit/version resolution with the decision logic kept pure and network I/O in thin wrappers, so it's testable without hitting GitHub.updatecompares installed commit vs remote ref head, falls back to version comparison for pre-manifest installs, and reports why it reached its verdict.--checkreports without installing; otherwise it re-runs the installer.--versionreads the real package version.Verification
Live against GitHub, all three states:
already up to date — installed from the current commitUpdate available — the tracked branch has moved on (0000000 → cf475f0)Update available — this install predates update tracking…30 tests pass in
packages/cli(10 new),npm run build:cliclean,sh -nclean on the installer, written manifest round-trips as valid JSON.Found but not fixed here
remove/uninstallis the same kind of stub, and worse — it printsRemoved LogicSRC CLI.while deleting nothing, so anyone running it believes their install is gone.install.shalready has a workingdo_uninstallto wire it to.scripts/install.shprintsInstalled: commandboard (latest)— looks like a stale copy from another product. The installer actually served at logicsrc.com isapps/logicsrc-web/public/install.sh, the one changed here.🤖 Generated with Claude Code